<?php 
namespace Application\Controller;


use ApplicationTest\Bootstrap;
use Zend\Mvc\Router\Http\TreeRouteStack as HttpRouter;
use Zend\Console\Request;
use Zend\Mvc\Router\RouteMatch;
use Zend\Mvc\MvcEvent;
use PHPUnit_Framework_TestCase;


class IndexControllerTest extends \PHPUnit_Framework_TestCase
{
	protected $controller;
	protected $request;
	protected $response;
	protected $routeMatch;
	protected $event;
	
	/* !CodeTemplates.overridecomment.nonjd!
	 * @see PHPUnit_Framework_TestCase::setUp()
	 */
	protected function setUp() {
		// TODO 自动生成的方法存根
		$serviceManager = Bootstrap::getServiceManager();
		$this->controller = new IndexController();
		$this->request = new Request();
		$this->routeMatch = new RouteMatch(array('controller' => 'index'));
		$this->event = new MvcEvent();
		$config = $serviceManager->get('Config');
		$routeConfig = isset($config['route']) ? $config['route'] : array();
		$router = HttpRouter::factory($routeConfig);
		
		$this->event->setRouter($router);
		$this->event->setRouteMatch($this->routeMatch);
		$this->controller->setEvent($this->event);
		$this->controller->setServiceLocator($serviceManager);
	}
	
	public function testIndexActionCanBeAccessed()
	{
		$this->routeMatch->setParam('action', 'index');
		
		$result = $this->controller->dispatch($this->request);
		$response = $this->controller->getResponse();
		$this->assertEquals(200, $response->getStatusCode());
	}

	
	
}
?>